﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace UtfprLibrary.Windows.Forms.ComponentModel {
    /// <summary>
    /// TODO
    /// </summary>
    public class Updating : UBNState {
        /// <summary>
        /// TODO
        /// </summary>
        /// <param name="navigator"></param>
        public Updating(UtfprBindingNavigatorBase navigator) : base(navigator) { }

        /// <summary>
        /// TODO
        /// </summary>
        public override void Cancel() {
            if (Navigator.CurrentMode == UBNModeEnum.Master) {
                Navigator.AddNewItem.UtfprControlEnabled = true;
                Navigator.DeleteItem.UtfprControlEnabled = true;
                Navigator.EditItem.UtfprControlEnabled = true;
                Navigator.CancelItem.UtfprControlEnabled = false;
                Navigator.SaveItem.UtfprControlEnabled = false;
                Navigator.QueryItem.UtfprControlEnabled = true;
                Navigator.RefreshItem.UtfprControlEnabled = true;
                Navigator.DuplicateItem.UtfprControlEnabled = true;
            } else {
                Navigator.AddNewItem.UtfprControlEnabled = true;
                Navigator.DeleteItem.UtfprControlEnabled = true;
                Navigator.EditItem.UtfprControlEnabled = true;
                Navigator.CancelItem.UtfprControlEnabled = false;
                Navigator.SaveItem.UtfprControlEnabled = false;
            }

            Navigator.CurrentState = UBNStateEnum.Searching;
        }

        /// <summary>
        /// TODO
        /// </summary>
        public override void Save() {
            if (Navigator.CurrentMode == UBNModeEnum.Master) {
                Navigator.AddNewItem.UtfprControlEnabled = true;
                Navigator.DeleteItem.UtfprControlEnabled = true;
                Navigator.EditItem.UtfprControlEnabled = true;
                Navigator.CancelItem.UtfprControlEnabled = false;
                Navigator.SaveItem.UtfprControlEnabled = false;
                Navigator.QueryItem.UtfprControlEnabled = true;
            } else {
                Navigator.AddNewItem.UtfprControlEnabled = true;
                Navigator.DeleteItem.UtfprControlEnabled = true;
                Navigator.EditItem.UtfprControlEnabled = true;
                Navigator.CancelItem.UtfprControlEnabled = false;
                Navigator.SaveItem.UtfprControlEnabled = false;
            }

            Navigator.CurrentState = UBNStateEnum.Searching;
        }
    }
}
